package com.flute.framework.monitor;

import java.util.Date;

public class DateFilter {

	public static StandardDate MIN_DATE = new StandardDate(
			"2000-01-01 00:00:00");

	private StandardDate start;
	private StandardDate end;

	public DateFilter() {

	}

	public DateFilter(StandardDate start, StandardDate end) {
		super();
		this.start = start;
		this.end = end;
	}

	public static StandardDate getMaxDate() {
		return new StandardDate(new Date());
	}

	public static DateFilter getAllDate() {
		return new DateFilter(MIN_DATE, getMaxDate());
	}

	public static DateFilter monthAgo(int month) {
		return new DateFilter(new StandardDate((new Date().getTime() - Long
				.valueOf(1000L * 3600 * 24 * 30 * month))), getMaxDate());
	}

	public static DateFilter dayAgo(int day) {
		return new DateFilter(new StandardDate(
				(new Date().getTime() - 1000L * 3600 * 24 * day)), getMaxDate());
	}

	public static DateFilter hourAgo(int hour) {
		return new DateFilter(new StandardDate(new Date().getTime() - 1000L
				* 3600 * hour), getMaxDate());
	}

	public static DateFilter minuteAgo(int minute) {
		return new DateFilter(new StandardDate(new Date().getTime() - 1000L
				* 60 * minute), getMaxDate());
	}

	public StandardDate getStart() {
		return start;
	}

	public void setStart(StandardDate start) {
		this.start = start;
	}

	public StandardDate getEnd() {
		return end;
	}

	public void setEnd(StandardDate end) {
		this.end = end;
	}

	public boolean concludeDate(StandardDate date) {
		// System.out.println(date.toDateString());
		// System.out.println(start.toDateString());
		// System.out.println(end.toDateString());

		return date.between(start, end);
	}

}
